package jdbcinterface;

import java.sql.ResultSet;
import java.sql.SQLException;

import rmi.DatabaseMetaDataAdapter;
import rmi.RemoteDbMeta;


public class GoggleDBMeta extends DatabaseMetaDataAdapter {
	RemoteDbMeta rdbm = null ;
	
	public GoggleDBMeta ( RemoteDbMeta r )  throws SQLException {
		try {
			rdbm = r ; 
		} catch ( Exception e ) {
			throw new SQLException ( "failed to get table info") ; 
		}
	}
	
	public String getDatabaseProductName() {
		return "Goggle Database, produced by S,D,L" ; 
	}
	
	public String getDatabaseProductVersion() {
		return "1.0.0.0" ; 
	}
	
	public String getDriverName() {
		return "Goggle Database Driver, Devloped by S,D,L"  ;
	}
	 
	public String getDriverVersion() { 
		return "1.0.0.0" ; 
	}
	
	public ResultSet getTables(String arg0, String arg1, String arg2,
			String[] arg3) throws SQLException {
		try {
			return new GoggleResultSet ( rdbm.getTables() );
		}
		catch ( Exception e )  {
			throw new SQLException ( "error while retrieve db matadata") ; 
		}
	}
	
	public ResultSet getIndexInfo(String arg0, String arg1, String arg2,
			boolean arg3, boolean arg4) throws SQLException {
		try {
			return new GoggleResultSet ( rdbm.getIndex( arg2 ) );
		}
		catch ( Exception e )  {
			throw new SQLException ( "error while retrieve db matadata") ; 
		}
	}
	
	public ResultSet getColumns(String arg0, String arg1, String arg2,
			String arg3) throws SQLException { 
		try {
			return new GoggleResultSet ( rdbm.getColumn( arg2 ) );
		}
		catch ( Exception e )  {
			throw new SQLException ( "error while retrieve db matadata") ; 
		}		
	}
	
	public ResultSet getSchemas() throws SQLException {
		return null ; 
	}
	
}
